// 使用Promise实现每隔1秒输出1,2,3

const arr = [1, 2, 3];

const result = arr.reduce(
  (p, x) =>
    p.then(new Promise((r) => setTimeout(() => r(console.log(x)), 1000))),
  Promise.resolve()
);

Promise.resolve()
  .then(new Promise((r) => setTimeout(() => r(console.log(1)), 1000)))
  .then(new Promise((r) => setTimeout(() => r(console.log(2)), 1000)))
  .then(new Promise((r) => setTimeout(() => r(console.log(3)), 1000)));
